﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using NetSysData;

namespace BladeTecWebApplication.Admin
{
	public partial class ViewQuizzes : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				NetSysData.NetSysData data = new NetSysData.NetSysData();
				GetQuizList_Result[] quizzes = data.GetQuizList();

				gvQuizzes.DataSource = quizzes;
				gvQuizzes.DataBind();

			}
		}

		private string getAllowBacktrackText(int allow)
		{
			return (allow == 0) ? "No" : "Yes";
		}

		protected void btnDelete_Click(object sender, EventArgs e)
		{
			int result;
			NetSysData.NetSysData data = new NetSysData.NetSysData();
			foreach (string s in Request.Form)
			{
				if (s.IndexOf("quiz_") == 0)
				{
					int quiz_id = Int32.Parse(Request.Form.Get(s));
					result = data.DeleteQuiz(quiz_id);
					if (result == -2)
					{
						pnlErrorDelete1.Visible = true;
					}
				}
			}

			GetQuizList_Result[] quizzes = data.GetQuizList();

			gvQuizzes.DataSource = quizzes;
			gvQuizzes.DataBind();
		}
	}
}